import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

export function register(data) {
  return request({
    url: '/user/addUser',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout(data) {
  return request({
    url: '/user/logout',
    method: 'post',
    params: { userId: data.userId }
  })
}

export function cancellation(data) {
  return request({
    url: '/user/cancellation',
    method: 'post',
    data
  })
}

export function edit(data) {
  return request({
    url: '/user/edit',
    method: 'post',
    data
  })
}

export function delUser(data) {
  return request({
    url: '/user/delUser',
    method: 'get',
    params: { id: data.id.id, adminId: data.adminId }
  })
}

export function findUserById(id) {
  return request({
    url: '/user/findUserById',
    method: 'get',
    params: id
  })
}

export function countAuthorsArticles(id) {
  return request({
    url: '/user/countAuthorsArticles',
    method: 'get',
    params: id
  })
}
// 关注
export function focus(data) {
  return request({
    url: '/user/focus',
    method: 'post',
    data
  })
}
// 取消关注
export function cancelFocus(data) {
  return request({
    url: '/user/cancelFocus',
    method: 'post',
    data
  })
}

// 查询是否已经被关注
export function isFocused(data) {
  return request({
    url: '/user/isFocused',
    method: 'post',
    data
  })
}

export function findMyFocusUserList(data) {
  return request({
    url: '/user/myFocusUsers',
    method: 'get',
    params: { userId: data.userId }
  })
}

// 获取我的收藏
export function getMyCollection(data) {
  return request({
    url: '/user/myCollections',
    method: 'get',
    params: { userId: data.userId }
  })
}

export function unReadCount(data) {
  return request({
    url: '/user/unReadCount',
    method: 'get',
    params: { userId: data.userId }
  })
}

export function uploadFile(data) {
  return request({
    url: '/user/toBeConsultant',
    method: 'post',
    data
  })
}

export function collectionCount(data) {
  return request({
    url: '/user/collectionCount',
    method: 'get',
    params: { userId: data.userId }
  })
}

export function getCreditToCount(data) {
  return request({
    url: '/user/getCreditToCount',
    method: 'get',
    params: { userId: data.userId }
  })
}

export function getConsultantList(data) {
  return request({
    url: '/user/getConsultantList',
    method: 'get',
    params: { username: data.username, skillFieldId: data.skillFieldId, pageIndex: data.pageIndex }
  })
}

export function getReplyLikeCollectCounts(data) {
  return request({
    url: '/user/getReplyLikeCollectCounts',
    method: 'get',
    params: { userId: data.userId }
  })
}
